
import * as setting from '@/config/setting.js'
import { get, post } from '@/api/http.js'


// 获取accessToken
export function getAccessToken() {
  return get(setting.dingding + setting.gettoken, {
	  "appkey": setting.clientId,
	  "appsecret": setting.secretId
  })
}

// 获取用户信息
export function getUserInfo(access_token) {
  return get(setting.dingding + setting.getuserinfo, {
	  "access_token": access_token,
	  "code": uni.getStorageSync(setting.authCode)
  })
}

// 获取用户详细信息
export function getUserDetailInfo() {
  return get(setting.dingding + setting.getuserdetailinfo, {
	  "access_token": uni.getStorageSync(setting.accessToken),
	  "userid": uni.getStorageSync(setting.userInfo).userid
  })
}


// 如果用户不存在则创建用户（自有后端）
export function getUserOrCreate(data) {
  return get(setting.api + setting.get_or_create_user, data)
}

// 获取用户数据（自有后端）
export function getUserUineData(data) {
  return get(setting.api + setting.get_user_dine_data, data)
}

// 定/退餐（自有后端）
export function ddineMeal(data) {
  return get(setting.api + setting.ddine_meal, data)
}

// 获取全局设置（自有后端）
export function ddineGetSetting(data) {
  return get(setting.api + setting.ddine_get_setting, data)
}

// 更新全局设置（自有后端）
export function ddineSetting(data) {
  return get(setting.api + setting.ddine_setting, data)
}

// 统计份数（自有后端）
export function ddineStatistics() {
  return get(setting.api + setting.ddine_statistics)
}